import axios from "axios";
// 实例化axios
var service = axios.create({
    timeout: 10 * 1000,
    baseURL: process.env.REACT_APP_BASE_URL //基准路径
})

//设置请求拦截器
service.interceptors.request.use(
    (config) => {
        config.headers['token'] = ""
        // config.headers['token'] = store.getState().userlist.token
        return config
    },
    (error) => {
        return Promise.reject(error)
    }
)

//设置响应拦截器
service.interceptors.response.use(
    (res) => {
        return res
    },
    (error) => {
        if (error.response.status === "401") {
            // "登陆过期，请重新登录"
        } else if (error.response.status === "404") {
            // "访问路径有误"
        } else if (error.response.status === "500") {
            // "服务器内部有误"
        } else if (error.response.status === "503") {
            // "服务器不可用"
        }
        return Promise.reject(error)
    }
)
export default service;
